<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:head>
    </h:head>
    <h:body>
        <ui:composition template="/templates/template.xhtml">
            <ui:define name="content">
                <p:growl id="growl" globalOnly="true" sticky="false"/>
                <div style="width: 600px">

                    <h:form>
                        <p:panel header="#{tekster.Reg_larer}" >  
                            <h:panelGrid columns="3">
                                <h:outputText value="#{tekster.Navn}"/>
                                <p:inputText id="navn" value="#{reg.l.navn}" required="true" requiredMessage="#{tekster.M_navn}"/>
                                <p:message for="navn"/>

                                <h:outputText value="#{tekster.Passord}"/>  
                                <p:password id="pw1" value="#{reg.l.passord}" match="pw2" required="true" requiredMessage="#{tekster.M_passord}" validatorMessage="#{tekster.F_passord_stemmer_ikke}"/>  
                                <p:message for="pw1"/>

                                <h:outputText value="#{tekster.Gjentapw}" />  
                                <p:password id="pw2" value="#{reg.l.passord2}" required="true" requiredMessage="#{tekster.M_passord2}"/>  
                                <p:message for="pw2"/>
                            </h:panelGrid>  

                            <p:commandButton ajax="false" value="#{tekster.Registrer}" actionListener="#{reg.regAnsattGrowl}"/>

                            <br/>
                        </p:panel> 
                        <br/>
                        <p:dataTable value="#{reg.ansatte}"
                                     var="ll" 
                                     id="display"
                                     editable="true"
                                     paginator="true"
                                     rows="5"
                                     paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}">

                            <f:facet name="header">  
                                <h:outputText value="#{tekster.L_registrert} #{reg.ansatte.size()}"/>
                            </f:facet>  

                            <p:column headerText="#{tekster.Navn}">
                                <p:cellEditor>  
                                    <f:facet name="output">  
                                        <h:outputText value="#{ll.navn}"/>  
                                    </f:facet>  
                                    <f:facet name="input">  
                                        <p:inputText value="#{ll.navn}" label="#{tekster.Navn}"/>  
                                    </f:facet>  
                                </p:cellEditor> 
                            </p:column>
                            <p:column headerText="#{tekster.Passord}">
                                <p:cellEditor>  
                                    <f:facet name="output">  
                                        <h:outputText value="#{ll.passord}" />  
                                    </f:facet>  
                                    <f:facet name="input">  
                                        <p:inputText value="#{ll.passord}" label="#{tekster.Navn}"/>  
                                    </f:facet>  
                                </p:cellEditor> 
                            </p:column>
                            <p:column headerText="#{tekster.Aktiv}">
                                <p:cellEditor>
                                    <f:facet name="output">
                                        <h:outputText rendered="#{ll.aktiv}" value="#{tekster.Aktiv}"/>
                                        <h:outputText rendered="#{!ll.aktiv}" value="#{tekster.Inaktiv}"/>
                                    </f:facet>
                                    <f:facet name="input">
                                        <p:selectOneMenu value="#{ll.aktiv}">
                                            <f:selectItem itemValue="true" itemLabel="#{tekster.Aktiv}"/>
                                            <f:selectItem itemValue="false" itemLabel="#{tekster.Inaktiv}"/>
                                        </p:selectOneMenu>
                                    </f:facet>
                                </p:cellEditor>
                            </p:column>
                            <p:column>
                                <p:rowEditor/>
                            </p:column>
                        </p:dataTable>
                        <p:commandButton immediate="true" ajax="false" value="#{tekster.Lagre}" actionListener="#{reg.lagreAnsattGrowl}"/>
                    </h:form>
                </div>
            </ui:define>

            <ui:define name="left">
                <div align="center">
                    <h:commandLink action="/index?faces-redirect=true" immediate="true">
                        <h:graphicImage library="images" name="home.png"/>
                    </h:commandLink><br/><br/>
                    <p:commandButton ajax="false" action="/Admin/admin?faces-redirect=true" value="#{tekster.Tilbake_admin}" immediate="true" />
                </div>  
            </ui:define>
        </ui:composition>
    </h:body>
</html>